home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ply15dat.zip / LOOKPOND.PI < prev    next >
Text File  |  1992-09-19  |  7KB  |  234 lines

  1. // Sample file demonstrating many of the features of Polyray.
  2. // Author: Alexander Enzmann
  3.  
  4. // So far this image contains the following:
  5. //   A looking pond with ripples defined as a height function
  6. //   Columns along the side of the pond
  7. //   Spot light illuminating parts of the image
  8. //   Two wood display cases containing various polynomial surfaces
  9.  
  10. viewpoint {
  11.    from <0, 8, -30>
  12.    at <0,0,10>
  13.    up <0,1,0>
  14.    angle 40
  15.    resolution 800, 600
  16.    aspect 1.3333
  17.    }
  18.  
  19. background <0, 0, 0>
  20. light <0, 50, -30>
  21. spot_light white, <20, 30, -10>, <0, 0, 0>, 3, 10, 15
  22.  
  23. include "..\colors.inc"
  24. include "quarts.inc"
  25.  
  26. // Define constants for the outer perimeter of the pond
  27. define tau (1 + sqrt(5))/2 // Golden Mean
  28. define width 5
  29. define length width * tau
  30. define height width * 0.10
  31.  
  32. // Define constants for the ripples in the pond
  33. define ripple_steps  80
  34. define ripple_height  height/1.5
  35. define ripple_freq    6.0
  36. define ripple_falloff  1
  37. define ripple_x0       0 // x position of first ripple
  38. define ripple_z0      -2 // y position of first ripple
  39. define ripple_x1       3 // x position of second ripple
  40. define ripple_z1       2 // y position of second ripple
  41. define ripple_function0
  42.    height/2 +
  43.    ripple_height *
  44.    cos(ripple_freq *
  45.        sqrt((x-ripple_x0)^2 + (z/tau-ripple_z0)^2)) *
  46.    exp(-ripple_falloff *
  47.        sqrt((x-ripple_x0)^2 + (z/tau-ripple_z0)^2))
  48. define ripple_function1
  49.    height/2 +
  50.    ripple_height *
  51.    cos(ripple_freq *
  52.        sqrt((x-ripple_x1)^2 + (z/tau-ripple_z1)^2) + 2.5) *
  53.    exp(-ripple_falloff *
  54.        sqrt((x-ripple_x1)^2 + (z/tau-ripple_z1)^2))
  55.  
  56. // Build the water surface from a bunch of ripples
  57. define ripple_function
  58.    ripple_function0 + ripple_function1
  59.  
  60. // Define the textures to use for the components of the pond
  61. define pond_edge_texture matte_red
  62. define basic_water_color <0.2, 0.5, 1>
  63. define water_texture
  64.    texture {
  65.       surface {
  66.          ambient basic_water_color, 0.2
  67.          diffuse basic_water_color, 0.8
  68.          specular white, 1
  69.          }
  70.       }
  71.  
  72. define pool
  73.    object {
  74.       // Top and bottom of the pond edge
  75.         object { box <-width - height, 0, length>,
  76.                      < width + height, height, length + height>
  77.                  pond_edge_texture }
  78.       + object { box <-width - height, 0, -length>,
  79.                      < width + height, height, -length - height>
  80.                  pond_edge_texture }
  81.  
  82.       // The two sides of the pond edge
  83.       + object { box <-width, 0, -length>,
  84.                      <-width - height, height, length>
  85.                  pond_edge_texture }
  86.       + object { box < width, 0, -length>,
  87.                      < width + height, height, length>
  88.                  pond_edge_texture }
  89.  
  90.       // Put a rippled surface into the pond
  91.       + object { height_fn ripple_steps, ripple_steps,
  92.                -width, width, -length, length,
  93.                            ripple_function
  94.                  water_texture }
  95.       }
  96.  
  97. define col_height width
  98. define col_radius height
  99. define cap_height height
  100. define cap_width 1.5 * col_radius
  101. define col_offset 2*cap_width
  102. define sin_color_offset (sin(3.14 * fmod(4*x*y*z, 1)) + 1) / 2
  103. define sin_color <sin_color_offset, 0, 1 - sin_color_offset>
  104. define column_texture
  105. texture {
  106.    special surface {
  107.       color sin_color
  108.       ambient 0.2
  109.       diffuse 0.8
  110.       specular white, 0.2
  111.       microfacet Reitz 10
  112.       }
  113.    translate <0, col_height/2, 0>
  114.    }
  115.  
  116. define column
  117.    object {
  118.      object { cylinder <0, 0, 0>, <0, col_height, 0>,
  119.                        col_radius }
  120.    + object { box <-cap_width, 0, -cap_width>,
  121.                   < cap_width, cap_height, cap_width> }
  122.    + object { box <-cap_width, col_height, -cap_width>,
  123.                   < cap_width, col_height+cap_height, cap_width> }
  124.    column_texture
  125.    }
  126.  
  127. define columns
  128. object {
  129.    // Columns along the sides of the pond
  130.      column { translate <-width-col_offset, 0, -length-col_offset> }
  131.    + column { translate < width+col_offset, 0, -length-col_offset> }
  132.    + column { translate <-width-col_offset, 0,  length+col_offset> }
  133.    + column { translate < width+col_offset, 0,  length+col_offset> }
  134.    }
  135.  
  136. // Define a texture for the ground plane
  137. //define ground_texture matte_white
  138. define ground_texture
  139. texture {
  140.    special surface {
  141.       normal <N[0], N[1], N[2]+sin(10*x)*sin(10*z)/2>
  142.       color cornflowerblue
  143.       ambient 0.2
  144.       diffuse 0.8
  145.       specular white, 0.2
  146.       microfacet Reitz 10
  147.       }
  148.    scale <10, 1, 10>
  149.    }
  150.  
  151. // Create a ground plane
  152. define ground
  153. object {
  154.    polynomial y
  155.    ground_texture
  156.    translate <0,-0.01,0>
  157.    }
  158.  
  159. define light_wood <0.3, 0.12, 0.03>
  160. define dark_wood <0.05, 0.01, 0.005>
  161. define xydist sqrt(x * x + y * y)
  162. define wood_turb 0.5
  163. define wood_fn  (sawtooth(xydist + wood_turb * noise(P,4)) + 1) / 2
  164. define wood_map
  165.    color_map(
  166.       [0.0, 0.8, light_wood, light_wood]
  167.       [0.8, 0.9, light_wood, dark_wood])
  168. define wood_texture
  169. texture {
  170.    special surface {
  171.       color wood_map[wood_fn]
  172.       ambient 0.2
  173.       diffuse 0.8
  174.       specular white, 0.3
  175.       microfacet Reitz 10
  176.       }
  177.    }
  178.  
  179. // Put together the first display case
  180. define display_case1
  181. object {
  182.      bicorn        { rotate <90, 0, 0> translate <-4.5, 0,  3> }
  183.    + bifolia       { rotate <90, 0, 0> translate <-1.5, 0,  3> }
  184.    + cassini       { rotate <90, 0, 0> translate < 1.5, 0,  3> }
  185.    + csaddle       { translate < 4.5, 0,  3> }
  186.    + devils_curve  { translate <-4.5, 0,  0> }
  187.    + folium        { rotate <0, 0, 45> translate <-2, 0,  0> }
  188.    + hyp_torus     { translate < 1.5, 0,  0> }
  189.    + kampyle       { translate < 4.5, 0,  0> }
  190.    + lemniscate    { translate <-4.5, 0, -3> }
  191.    + qloop         { translate <-1.5, 0, -3> }
  192.    + monkey_saddle { translate < 1.5, 0, -3> }
  193.    + par_torus     { translate < 4.5, 0, -3> }
  194.    + (  object { box <-7, -4, -5.5>, < 7, 0, 5.5> wood_texture }
  195.       - object { box <-6, -3, -4.5>, < 6, 1, 4.5> wood_texture })
  196.    scale <0.4, 0.4, 0.4>
  197.    rotate <-90, -90, 0>
  198.    translate <-width-3*col_offset, 2*col_height/3, -length/2>
  199.    shiny_red
  200.    }
  201.  
  202. // Put together the second display case
  203. define display_case2
  204. object {
  205.      piriform       { translate <-4.5, 0,  3> }
  206.    + quart_parab    { translate <-1.5, 0,  3> }
  207.    + quart_saddle   { translate < 1.5, 0,  3> }
  208.    + space_needle   { translate < 4.5, 0,  3> }
  209.    + parab4         { translate <-4.5, 0,  0> }
  210.    + steiner        { translate <-1.5, 0,  0> }
  211.    + strophoid      { translate < 1.5, 0,  0> }
  212.    + tear3          { translate < 4.5, 0,  0> }
  213.    + tear5          { translate <-4.5, 0, -3> }
  214.    + torus_5_2      { translate <-1.5, 0, -3> }
  215.    + crossed_trough { translate < 1.5, 0, -3> }
  216.    + twin_glob      { translate < 4.5, 0, -3> }
  217.    + (  object { box <-7, -4, -5.5>, < 7, 0, 5.5> wood_texture }
  218.       - object { box <-6, -3, -4.5>, < 6, 1, 4.5> wood_texture })
  219.    scale <0.4, 0.4, 0.4>
  220.    rotate <-90, -90, 0>
  221.    translate <-width-3*col_offset, 2*col_height/3, length/2>
  222.    shiny_red
  223.    }
  224.  
  225. // Put the scene together
  226. object {
  227.      pool
  228.    + ground
  229.    + columns
  230.    + display_case1
  231.    + display_case2
  232.    rotate <0, 80, 0>
  233.    }
  234.